﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Krile.Forms.ConfigForm.Children
{
    public partial class Appearance : Krilib.Control.ConfigPage
    {
        public Appearance()
        {
            InitializeComponent();
        }

        Font _font = null;
        Font font
        {
            get { return _font; }
            set
            {
                _font = value;
                fontSample.Font = value;
            }
        }

        private void Appearance_Load(object sender, EventArgs e)
        {
            this.font = Core.Config.Appearance.Font.Value;
            this.InterpolateMode.SelectedIndex = (int)Core.Config.Appearance.InterpolateMode - 1;
            this.ScrollbarWidth.Value = Core.Config.Appearance.ScrollbarWidth;
            this.ToolstripDesign.SelectedIndex = (int)Core.Config.Appearance.ToolStripDesign;
        }

        public override void Apply()
        {
            Core.Config.Appearance.Font.Value = this.font;
            Core.Config.Appearance.InterpolateMode = (System.Drawing.Drawing2D.InterpolationMode)(this.InterpolateMode.SelectedIndex + 1);
            Core.Config.Appearance.ScrollbarWidth = (int)this.ScrollbarWidth.Value;
            Core.Config.Appearance.ToolStripDesign = (Krile.Cores.Config._Appearance.ToolStripDesigns)this.ToolstripDesign.SelectedIndex;
        }

        private void FontSelectionButton_Click(object sender, EventArgs e)
        {
            using (var fs = new FontDialog())
            {
                fs.AllowSimulations = true;
                fs.AllowVectorFonts = true;
                fs.AllowVerticalFonts = false;
                fs.ScriptsOnly = true;
                fs.ShowApply = false;
                fs.ShowColor = false;
                fs.ShowEffects = false;
                fs.Font = font;
                if (fs.ShowDialog() == DialogResult.OK)
                {
                    font = fs.Font;
                }
            }
        }
    }
}
